
local ReadOnlyArray = {}
ReadOnlyArray.__cname = "util.ReadOnlyArray"
ReadOnlyArray.__index = function(self, key)
    if "number" == type(key) then
        return self:GetAt(key)
    end
    return ReadOnlyArray[key]
end

local ClearTypeEnum = {
    Reset = nil,
    FillNil = 1,
    Keep = 2,
}
ReadOnlyArray.ClearTypeEnum = ClearTypeEnum


function ReadOnlyArray.new(array)
    local obj = {}
    setmetatable(obj, ReadOnlyArray)
    obj:ctor(array)
    return obj
end

function ReadOnlyArray:ctor(array)
    assert(array.__cname == "util.Array")
    self.array = array
end

function ReadOnlyArray:Clear(clearType)
    self.array:Clear(clearType)
end

function ReadOnlyArray:GetCount()
    return self.count
end

function ReadOnlyArray:Add(v)
    self.arr:Add(v)
end

function ReadOnlyArray:InsertAt(index, v)
    error("readOnly: not support")
end

function ReadOnlyArray:GetAt(index)
    return self.array:GetAt(index)
end

function ReadOnlyArray:RemoveAt(index)
    error("readOnly: not support")
end

function ReadOnlyArray:RemoveRange(index, count)
    error("readOnly: not support")
end

function ReadOnlyArray:Remove(v)
    error("readOnly: not support")
end

function ReadOnlyArray:Contains(v)
    return self.array:Contains(v)
end

function ReadOnlyArray:IndexOf(v)
    return self.array:IndexOf(v)
end

function ReadOnlyArray:Find(matchFunc)
    return self.array:Find(matchFunc)
end

function ReadOnlyArray:LastIndexOf(v)
    return self.array:LastIndexOf(v)
end

function ReadOnlyArray:FindLast(matchFunc)
    return self.array:FindLast(matchFunc)
end

function ReadOnlyArray:Sort(func)
    error("readOnly: not support")
end

function ReadOnlyArray:Reverse()
    error("readOnly: not support")
end

function ReadOnlyArray:Shuffle()
    error("readOnly: not support")
end

function ReadOnlyArray:__tostring()
    return self.array:__tostring()
end

function ReadOnlyArray:GetIterator()
    return self.array:GetIterator()
end

function ReadOnlyArray:IsReadOnly()
    return true
end

return ReadOnlyArray
